import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ResponseServlet extends HttpServlet 
{
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException 
    {
        PrintWriter out = response.getWriter();
       
        String firstname = request.getParameter("firstname");
        String lastname = request.getParameter("lastname");
        String nickname = request.getParameter("nickname");
        String cellnum = request.getParameter("cellnum");
        String email = request.getParameter("email");
        
        String msg;
       
        if ((firstname != null) && (firstname.length() > 0)) 
        {
        	if ((lastname != null) && (lastname.length() > 0)) 
        	{
        		out.println("<h2>Hello, " + firstname + " " + lastname + "!</h2>");
        	}
        	else
        	{
        		msg = "Please enter your last name.";
        		out.print(msg);
        	}
        }
        
        if ((nickname != null) && (nickname.length() > 0))
        {
        	out.println("<h2>I can also call you " + nickname + " right?</h2>");
        }
        
        if ((cellnum != null) && (cellnum.length() > 0))
        {
        	out.println("<h2>Well I gotta go !! Text you later at " + cellnum + "</h2>");
        }
        
        if ((email != null) && (email.length() > 0))
        {
        	out.println("<h2>Thanks for the email " + email + "</h2>");
        }
    }
   
    public String getServletInfo() {
        return "The Response servlet says hello.";
    }
}